package casamento.util;

import java.util.ArrayList;
import java.util.List;

import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;

public class ValidaEmpresa implements ActionListener {

	@Override
	public void processAction(ActionEvent event) {

		UIComponent component = event.getComponent();
		UIInput nome = (UIInput) component.findComponent("nome");
		UIInput area = (UIInput) component.findComponent("area");
		UIInput cnpj = (UIInput) component.findComponent("cnpj");

		List<UIInput> erros = new ArrayList<UIInput>();
		erros.add(nome);
		erros.add(area);
		erros.add(cnpj);

		for (UIInput ui : erros) {
			if (ui.getValue().equals("") || ui.getValue() == null) {
				ui.getAttributes().put("style",
						"background:#f2dede; border-color:#cd0a0a");
			} else {
				ui.getAttributes().put("style", "");
			}
		}
	}
}
